<template>
  <a-modal
    :title="title"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <div style="width: 100%;text-align: center;margin-bottom: 10px;">
        <span style="font-size: 18px;font-weight: bold;">细纱</span>
      </div>
      <a-form-model :model="model" :form="form" :rules="rules" ref="form">
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="组织" prop="company">
              <j-dict-select-tag
                dictCode="crm_company,name,id"
                v-model="model.company"
                placeholder="请选择组织"
                @change="changeCompany"
              >
              </j-dict-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="车间" prop="workshop">
              <j-dict-select-tag
                placeholder="请选择车间"
                v-model="model.workshop"
                dictCode="workshop"
                @change="changeWorkShop"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="楼层" prop="floor">
              <j-dict-select-tag dictCode="floor" v-model="model.floor" placeholder="请选择楼层" @change="changeFloor">
              </j-dict-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="品种" prop="productType">
              <j-dict-select-tag
                placeholder="请选择品种"
                v-model="model.productType"
                @change="changePz"
                dictCode="crm_product_type_spun_yarn,product_type_full_name,id"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="细纱机台" prop="spunYarnDeviceIds">
              <a-space>
                <a-input placeholder="请选择" style="width:215px" readOnly v-model="model.spunYarnDeviceText"></a-input>
                <a-button type="primary" icon="plus" size="small" @click="showModal('devSnArea')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="细纱入库数量" prop="temOutput">
              <a-input-number v-model:value="model.inQuantity" style="width:215px"></a-input-number>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A品种">
              <j-dict-select-tag
                placeholder="请选择"
                v-model="model.aproductType"
                dictCode="crm_product_type_spun_yarn,product_type,id"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A开台(12)" prop="adeviceIds">
              <a-space>
                <a-input placeholder="请选择" style="width:215px" readOnly v-model="model.adeviceText"></a-input>
                <a-button type="primary" icon="plus" size="small" @click="ktOpen('jakt')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A开始时间" prop="aStartTime">
              <a-space>
                <a-date-picker
                  show-time
                  v-model:value="formAStartTime"
                  placeholder="选择日期"
                  style="width:215px"
                  :allowClear="false"
                  @change="changeAStartTime"
                />
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A结束时间" prop="aEndTime">
              <a-date-picker
                show-time
                v-model:value="formAEndTime"
                placeholder="选择日期"
                style="width:215px"
                :allowClear="false"
                @change="changeAEndTime"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B品种">
              <j-dict-select-tag
                placeholder="请选择"
                v-model="model.bproductType"
                dictCode="crm_product_type_spun_yarn,product_type,id"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B开台(12)" prop="bdeviceIds">
              <a-space>
                <a-input placeholder="请选择" style="width:215px" readOnly v-model="model.bdeviceText"></a-input>
                <a-button type="primary" icon="plus" size="small" @click="ktOpen('ybkt')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B开始时间" prop="aStartTime">
              <a-space>
                <a-date-picker
                  show-time
                  v-model:value="formBStartTime"
                  placeholder="选择日期"
                  style="width:215px"
                  :allowClear="false"
                  @change="changeBStartTime"
                />
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B结束时间" prop="aEndTime">
              <a-date-picker
                show-time
                v-model:value="formBEndTime"
                placeholder="选择日期"
                style="width:215px"
                :allowClear="false"
                @change="changeBEndTime"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <!--        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">-->
        <!--          <a-col :span="11">-->
        <!--            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="粗纱临时计划" prop="temOutput">-->
        <!--              <a-input-number v-model:value="model.temOutputRove" style="width:215px"></a-input-number>-->
        <!--            </a-form-model-item>-->
        <!--          </a-col>-->
        <!--          <a-col :span="11">-->
        <!--            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="粗纱设定车速" prop="speedSet">-->
        <!--              <a-input-number v-model:value="model.speedSetRove" style="width:215px"></a-input-number>-->
        <!--            </a-form-model-item>-->
        <!--          </a-col>-->
        <!--        </a-row>-->
        <a-divider />
        <div style="width: 100%;text-align: center;margin-bottom: 10px;">
          <span style="font-size: 18px;font-weight: bold;">前纺</span>
        </div>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="组织" prop="company">
              <j-dict-select-tag
                dictCode="crm_company,name,id"
                v-model="model.dailyPlanPreSpin.company"
                placeholder="请选择组织"
              >
              </j-dict-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="车间" prop="workshop">
              <j-dict-select-tag
                placeholder="请选择车间"
                v-model="model.dailyPlanPreSpin.workshop"
                dictCode="workshop"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="楼层" prop="floor">
              <j-dict-select-tag dictCode="floor" v-model="model.dailyPlanPreSpin.floor" placeholder="请选择楼层">
              </j-dict-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="工序">
              <j-dict-select-tag
                dictCode="working_procedure"
                v-model="model.dailyPlanPreSpin.workingProcedure"
                placeholder="请选择工序"
                disabled
              >
              </j-dict-select-tag>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="前纺品种">
              <j-dict-select-tag
                placeholder="请选择前纺品种"
                v-model="model.dailyPlanPreSpin.productType"
                dictCode="crm_product_type_rove,product_type,id"
                @change="changeQianFang"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="前纺车间调整粗纱">
              <a-space>
                <a-input
                  placeholder="请选择"
                  style="width:215px"
                  readOnly
                  v-model="model.dailyPlanPreSpin.preSpinDeviceText"
                ></a-input>
                <a-button type="primary" icon="plus" size="small" @click="ktOpenQianFang('CuSha')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A品种">
              <j-dict-select-tag
                placeholder="请选择甲A品种"
                v-model="model.dailyPlanPreSpin.aproductType"
                dictCode="crm_product_type_rove,product_type,id"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A开台">
              <a-space>
                <a-input
                  placeholder="请选择"
                  style="width:215px"
                  readOnly
                  v-model="model.dailyPlanPreSpin.adeviceText"
                ></a-input>
                <a-button type="primary" icon="plus" size="small" @click="ktOpenQianFang('CuSha', 'jakt')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A开始时间">
              <a-space>
                <a-date-picker
                  show-time
                  v-model:value="formAStartTimeQianFang"
                  placeholder="选择日期"
                  style="width:215px"
                  :allowClear="false"
                  @change="changeAStartTimeQianFang"
                />
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A结束时间">
              <a-date-picker
                show-time
                v-model:value="formAEndTimeQianFang"
                placeholder="选择日期"
                style="width:215px"
                :allowClear="false"
                @change="changeAEndTimeQianFang"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B品种">
              <j-dict-select-tag
                placeholder="请选择乙B品种"
                v-model="model.dailyPlanPreSpin.bproductType"
                dictCode="crm_product_type_rove,product_type,id"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B开台">
              <a-space>
                <a-input
                  placeholder="请选择"
                  style="width:215px"
                  readOnly
                  v-model="model.dailyPlanPreSpin.bdeviceText"
                ></a-input>
                <a-button type="primary" icon="plus" size="small" @click="ktOpenQianFang('CuSha', 'ybkt')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B开始时间">
              <a-space>
                <a-date-picker
                  show-time
                  v-model:value="formBStartTimeQianFang"
                  placeholder="选择日期"
                  style="width:215px"
                  :allowClear="false"
                  @change="changeBStartTimeQianFang"
                />
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B结束时间">
              <a-date-picker
                show-time
                v-model:value="formBEndTimeQianFang"
                placeholder="选择日期"
                style="width:215px"
                :allowClear="false"
                @change="changeBEndTimeQianFang"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <!-- <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="丙C品种">
              <j-dict-select-tag
                placeholder="请选择丙C品种"
                v-model="model.dailyPlanPreSpin.cproductType"
                dictCode="crm_product_type_rove,product_type,id"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="丙C开台">
              <a-space>
                <a-input
                  placeholder="请选择"
                  style="width:215px"
                  readOnly
                  v-model="model.dailyPlanPreSpin.cdeviceText"
                ></a-input>
                <a-button type="primary" icon="plus" size="small" @click="ktOpenQianFang('CuSha', 'bckt')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="丙C开始时间">
              <a-space>
                <a-date-picker
                  show-time
                  v-model:value="formCStartTimeQianFang"
                  placeholder="选择日期"
                  style="width:215px"
                  :allowClear="false"
                  @change="changeCStartTimeQianFang"
                />
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="丙C结束时间">
              <a-date-picker
                show-time
                v-model:value="formCEndTimeQianFang"
                placeholder="选择日期"
                style="width:215px"
                :allowClear="false"
                @change="changeCEndTimeQianFang"
              />
            </a-form-model-item>
          </a-col>
        </a-row> -->
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="前后工序调配">
              <a-input-number v-model:value="model.dailyPlanPreSpin.fixWeight" style="width:215px"></a-input-number>
            </a-form-model-item>
          </a-col>
          <a-col :span="11"> </a-col>
        </a-row>

        <a-divider />
        <div style="width: 100%;text-align: center;margin-bottom: 10px;">
          <span style="font-size: 18px;font-weight: bold;">络筒</span>
        </div>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="组织" prop="company">
              <j-dict-select-tag
                dictCode="crm_company,name,id"
                v-model="model.dailyPlanSpooling.company"
                placeholder="请选择组织"
              >
              </j-dict-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="车间" prop="workshop">
              <j-dict-select-tag placeholder="请选择车间" v-model="model.workshop" dictCode="workshop" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="楼层" prop="floor">
              <j-dict-select-tag dictCode="floor" v-model="model.dailyPlanSpooling.floor" placeholder="请选择楼层">
              </j-dict-select-tag>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="络筒品种" prop="productType">
              <j-dict-select-tag
                placeholder="请选择络筒品种"
                v-model="model.dailyPlanSpooling.productType"
                @change="changePzLuoTong"
                dictCode="crm_product_type_spooling,product_type_full_name,id"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="络筒机台" prop="spoolingDeviceIds">
              <a-space>
                <a-input
                  placeholder="请选择"
                  style="width:215px"
                  readOnly
                  v-model="model.dailyPlanSpooling.spoolingDeviceText"
                ></a-input>
                <a-button
                  type="primary"
                  icon="plus"
                  size="small"
                  @click="showModalLuoTong('equipmentScopeLt')"
                ></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A品种">
              <j-dict-select-tag
                placeholder="请选择"
                v-model="model.dailyPlanSpooling.aproductType"
                dictCode="crm_product_type_spooling,product_type_full_name,id"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A开台" prop="adeviceIds">
              <a-space>
                <a-input
                  placeholder="请选择"
                  style="width:215px"
                  readOnly
                  v-model="model.dailyPlanSpooling.adeviceText"
                ></a-input>
                <a-button type="primary" icon="plus" size="small" @click="showModalLuoTong('jakt')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A开始时间" prop="aStartTime">
              <a-space>
                <a-date-picker
                  show-time
                  v-model:value="formAStartTimeLuoTong"
                  placeholder="选择日期"
                  style="width:215px"
                  :allowClear="false"
                  @change="changeAStartTimeLuoTong"
                />
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="甲A结束时间" prop="aEndTime">
              <a-date-picker
                show-time
                v-model:value="formAEndTimeLuoTong"
                placeholder="选择日期"
                style="width:215px"
                :allowClear="false"
                @change="changeAEndTimeLuoTong"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B品种">
              <j-dict-select-tag
                placeholder="请选择"
                v-model="model.dailyPlanSpooling.bproductType"
                dictCode="crm_product_type_spooling,product_type_full_name,id"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B开台" prop="bdeviceIds">
              <a-space>
                <a-input
                  placeholder="请选择"
                  style="width:215px"
                  readOnly
                  v-model="model.dailyPlanSpooling.bdeviceText"
                ></a-input>
                <a-button type="primary" icon="plus" size="small" @click="showModalLuoTong('ybkt')"></a-button>
              </a-space>
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B开始时间" prop="aStartTime">
              <a-space>
                <a-date-picker
                  show-time
                  v-model:value="formBStartTimeLuoTong"
                  placeholder="选择日期"
                  style="width:215px"
                  :allowClear="false"
                  @change="changeBStartTimeLuoTong"
                />
              </a-space>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="乙B结束时间" prop="aEndTime">
              <a-date-picker
                show-time
                v-model:value="formBEndTimeLuoTong"
                placeholder="选择日期"
                style="width:215px"
                :allowClear="false"
                @change="changeBEndTimeLuoTong"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="11">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="络筒入库数量" prop="inQuantity">
              <a-input-number v-model:value="model.dailyPlanSpooling.inQuantity" style="width:215px"></a-input-number>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-divider />
        <a-alert type="warning">
          <div slot="message" style="color: #fa9124;">
            <a-icon type="bar-chart" />
            应开台数：<span style="color:#292B3D">细纱机：</span>{{ adds.devSnAreaLength }}
            <span style="color:#292B3D">、甲A开台：</span>
            {{ adds.jaktLength }}<span style="color:#292B3D">、乙B开台：</span> {{ adds.ybktLength
            }}<span style="color:#292B3D">、欠开：</span>{{ adds.qk }}
          </div>
        </a-alert>
      </a-form-model>
    </a-spin>
    <jitai-modal ref="xishaModal" @getDevSnArr="getDevSnArr"></jitai-modal>
    <luotong-jitai-modal ref="luotongJitaiModal" @getDevSnArr="getDevSnArrLuoTong"></luotong-jitai-modal>
    <cu-sha-ji-tai-modal ref="qianfangModal" @getDevSnArr="getDevSnArrQianFang"></cu-sha-ji-tai-modal>
  </a-modal>
</template>

<script>
import { httpAction } from '@/api/manage'
import JitaiModal from './JitaiModal'
import LuotongJitaiModal from './LuotongJitaiModal'
import CuShaJiTaiModal from './CuShaJiTaiModal'
import JEditor from '@/components/jeecg/JEditor'
import JSwitch from '@/components/jeecg/JSwitch'
import { message } from 'ant-design-vue'
import moment from 'moment'
import { productTypeRoveList, productTypeSpoolingList, productTypeSpunYarn } from '../../../../api/customApi'

export default {
  name: 'QinghuaModal',
  components: {
    JEditor,
    JSwitch,
    JitaiModal,
    LuotongJitaiModal,
    CuShaJiTaiModal
  },
  props: {
    planTime: String
  },
  data() {
    return {
      equipmentScopeText: '',
      formAStartTime: this.planTime + ' 00:00:00',
      formAEndTime: this.planTime + ' 12:00:00',
      formBStartTime: this.planTime + ' 12:00:00',
      formBEndTime: this.planTime + ' 24:00:00',
      formAStartTimeLuoTong: this.planTime + ' 00:00:00',
      formAEndTimeLuoTong: this.planTime + ' 12:00:00',
      formBStartTimeLuoTong: this.planTime + ' 12:00:00',
      formBEndTimeLuoTong: this.planTime + ' 24:00:00',

      formAStartTimeQianFang: this.planTime + ' 00:00:00',
      formAEndTimeQianFang: this.planTime + ' 12:00:00',
      formBStartTimeQianFang: this.planTime + ' 12:00:00',
      formBEndTimeQianFang: this.planTime + ' 24:00:00',
      // formCStartTimeQianFang: this.planTime + ' 16:00:00',
      // formCEndTimeQianFang: this.planTime + ' 24:00:00',
      adds: {
        org: '',
        cj: '',
        devSnArea: [],
        equipmentScope: [],
        equipmentScopeLt: [],
        lc: '',
        pz: '',
        pzCs: '',
        qk: 0,
        time: '',
        jakt: [],
        ybkt: [],
        pzja: '',
        pzyb: '',
        changeCompany: '',
        workshop: '',
        floor: '',
        devSnAreaLength: 0,
        jaktLength: 0,
        ybktLength: 0
      },
      dailyPlanSpooling: {
        org: '',
        cj: '',
        devSnArea: [],
        equipmentScope: [],
        equipmentScopeLt: [],
        lc: '',
        pz: '',
        pzCs: '',
        qk: 0,
        time: '',
        jakt: [],
        ybkt: [],
        // bckt: [],
        pzja: '',
        pzyb: '',
        // pzbc: ''
      },
      addsQianFang: {
        org: '',
        cj: '',
        devSnArea: [],
        equipmentScope: [],
        QingHua: [],
        ShuMian: [],
        BingTiao: [],
        CuSha: [],
        equipmentScopeLt: [],
        lc: '',
        pz: '',
        pzCs: '',
        qk: 0,
        time: '',
        jakt: [],
        ybkt: [],
        pzja: '',
        pzyb: ''
      },
      title: '操作',
      visible: false,
      disable: true,
      model: {
        company: null,
        workshop: null,
        floor: null,
        productTypeRove: null,
        roveDeviceIds: '',
        roveDeviceText: '',
        spunYarnDeviceIds: '',
        spunYarnDeviceText: '',
        productType: null,
        spoolingDeviceIds: '',
        spoolingDeviceText: '',
        dailyPlanPreSpin: {
          company: null,
          workshop: null,
          floor: null,
          workingProcedure: '5',
          preSpinDeviceText: '',
          preSpinDeviceIds: [],
          productTypeRove: null,
          roveDeviceIds: '',
          roveDeviceText: '',
          spunYarnDeviceIds: '',
          spunYarnDeviceText: '',
          productType: null,
          spoolingDeviceIds: '',
          spoolingDeviceText: '',
          adeviceIds: '',
          adeviceText: '',
          aproductType: null,
          bdeviceIds: '',
          bdeviceText: '',
          bproductType: null,
          // cdeviceIds: '',
          // cdeviceText: '',
          // cproductType: null,
          unOpen: 0,
          fixWeight: null,
          ingotslds: '',
          aStartTime: this.planTime + ' 00:00:00',
          aEndTime: this.planTime + ' 12:00:00',
          bStartTime: this.planTime + ' 12:00:00',
          bEndTime: this.planTime + ' 24:00:00',
          // cStartTime: this.planTime + ' 16:00:00',
          // cEndTime: this.planTime + ' 24:00:00',
          // planTime: moment(new Date()).format('YYYY-MM-DD'),
          planTime: this.planTime
        },
        dailyPlanSpooling: {
          company: null,
          workshop: null,
          floor: null,
          productTypeRove: null,
          roveDeviceIds: '',
          roveDeviceText: '',
          spunYarnDeviceIds: '',
          spunYarnDeviceText: '',
          productType: null,
          spoolingDeviceIds: '',
          spoolingDeviceText: '',
          adeviceIds: '',
          adeviceText: '',
          aproductType: null,
          bdeviceIds: '',
          bdeviceText: '',
          bproductType: null,
          // cdeviceIds: '',
          // cdeviceText: '',
          // cproductType: null,
          unOpen: 0,
          ingotslds: '',
          aStartTime: this.planTime + ' 00:00:00',
          aEndTime: this.planTime + ' 12:00:00',
          bStartTime: this.planTime + ' 12:00:00',
          bEndTime: this.planTime + ' 24:00:00',
          // cStartTime: this.planTime + ' 16:00:00',
          // cEndTime: this.planTime + ' 24:00:00',
          // planTime: moment(new Date()).format('YYYY-MM-DD'),
          planTime: this.planTime
        },
        adeviceIds: '',
        adeviceText: '',
        aproductType: null,
        bdeviceIds: '',
        bdeviceText: '',
        bproductType: null,
        unOpen: 0,
        aStartTime: this.planTime + ' 00:00:00',
        aEndTime: this.planTime + ' 12:00:00',
        bStartTime: this.planTime + ' 12:00:00',
        bEndTime: this.planTime + ' 24:00:00',
        // planTime: moment(new Date()).format('YYYY-MM-DD'),
        planTime: this.planTime
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 9 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 14 }
      },
      confirmLoading: false,
      form: this.$form.createForm(this),
      rules: {
        company: [{ required: true, message: '请选择组织', trigger: 'blur' }],
        workshop: [{ required: true, message: '请选择车间', trigger: 'blur' }],
        floor: [{ required: true, message: '请选择楼层', trigger: 'blur' }],
        productType: [{ required: true, message: '请选择品种', trigger: 'blur' }],
        // spoolingDeviceIds: [{ required: true, message: '请选择', trigger: 'blur' }],
        // productType: [{ required: true, message: '请选择前纺品种', trigger: 'blur' }],
        roveDeviceIds: [{ required: true, message: '请选择前纺车间调整粗纱', trigger: 'blur' }],
        spunYarnDeviceIds: [{ required: true, message: '请选择细纱机台', trigger: 'blur' }],
        adeviceIds: [{ required: true, message: '请选择', trigger: 'blur' }],
        bdeviceIds: [{ required: true, message: '请选择', trigger: 'blur' }]
      },
      url: {
        add: '/crm_daily_plan_spun_yarn/crmDailyPlanSpunYarn/add',
        edit: '/crm_daily_plan_spun_yarn/crmDailyPlanSpunYarn/edit'
      }
    }
  },
  created() {},
  methods: {
    add() {
      this.disable = false
      this.adds = {
        org: '',
        cj: '',
        devSnArea: [],
        equipmentScope: [],
        equipmentScopeLt: [],
        lc: '',
        pz: '',
        pzCs: '',
        qk: 0,
        time: '',
        jakt: [],
        ybkt: [],
        pzja: '',
        pzyb: '',
        changeCompany: '',
        workshop: '',
        floor: '',
        devSnAreaLength: 0,
        jaktLength: 0,
        ybktLength: 0
      }
      this.dailyPlanSpooling = {
        org: '',
        cj: '',
        devSnArea: [],
        equipmentScope: [],
        equipmentScopeLt: [],
        lc: '',
        pz: '',
        pzCs: '',
        qk: 0,
        time: '',
        jakt: [],
        ybkt: [],
        // bckt: [],
        pzja: '',
        pzyb: '',
        // pzbc: ''
      }
      this.addsQianFang = {
        org: '',
        cj: '',
        devSnArea: [],
        equipmentScope: [],
        QingHua: [],
        ShuMian: [],
        BingTiao: [],
        CuSha: [],
        equipmentScopeLt: [],
        lc: '',
        pz: '',
        pzCs: '',
        qk: 0,
        time: '',
        jakt: [],
        ybkt: [],
        pzja: '',
        pzyb: ''
      }

      this.model.company = '1771136798305476610'
      this.model.floor = 2
      this.formAStartTime = this.planTime + ' 00:00:00'
      this.formAEndTime = this.planTime + ' 12:00:00'
      this.formBStartTime = this.planTime + ' 12:00:00'
      this.formBEndTime = this.planTime + ' 24:00:00'
      this.formAStartTimeLuoTong = this.planTime + ' 00:00:00'
      this.formAEndTimeLuoTong = this.planTime + ' 12:00:00'
      this.formBStartTimeLuoTong = this.planTime + ' 12:00:00'
      this.formBEndTimeLuoTong = this.planTime + ' 24:00:00'
      this.formAStartTimeQianFang = this.planTime + ' 00:00:00'
      this.formAEndTimeQianFang = this.planTime + ' 12:00:00'
      this.formBStartTimeQianFang = this.planTime + ' 12:00:00'
      this.formBEndTimeQianFang = this.planTime + ' 24:00:00'
      // this.formCStartTimeQianFang = this.planTime + ' 16:00:00'
      // this.formCEndTimeQianFang = this.planTime + ' 24:00:00'

      this.model.dailyPlanSpooling.company = '1771136798305476610'
      this.model.dailyPlanSpooling.floor = 2
      this.model.dailyPlanSpooling.aStartTime = this.planTime + ' 00:00:00'
      this.model.dailyPlanSpooling.aEndTime = this.planTime + ' 12:00:00'
      this.model.dailyPlanSpooling.bStartTime = this.planTime + ' 12:00:00'
      this.model.dailyPlanSpooling.bEndTime = this.planTime + ' 24:00:00'
      this.model.dailyPlanSpooling.planTime = this.planTime

      this.model.dailyPlanPreSpin.company = '1771136798305476610'
      this.model.dailyPlanPreSpin.floor = 2
      this.model.dailyPlanPreSpin.aStartTime = this.planTime + ' 00:00:00'
      this.model.dailyPlanPreSpin.aEndTime = this.planTime + ' 12:00:00'
      this.model.dailyPlanPreSpin.bStartTime = this.planTime + ' 12:00:00'
      this.model.dailyPlanPreSpin.bEndTime = this.planTime + ' 24:00:00'
      // this.model.dailyPlanPreSpin.cStartTime = this.planTime + ' 16:00:00'
      // this.model.dailyPlanPreSpin.cEndTime = this.planTime + ' 24:00:00'
      this.model.dailyPlanPreSpin.planTime = this.planTime

      this.model.aStartTime = this.planTime + ' 00:00:00'
      this.model.aEndTime = this.planTime + ' 12:00:00'
      this.model.bStartTime = this.planTime + ' 12:00:00'
      this.model.bEndTime = this.planTime + ' 24:00:00'
      this.model.planTime = this.planTime
      this.edit({}, 1)
    },
    edit(record, isEdit) {
      if (isEdit != 1) {
        this.model = Object.assign({}, record)
      }

      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.disable = true
      this.model.roveDeviceText = ''
      this.model.roveDeviceIds = ''
      this.model.spoolingDeviceText = ''
      this.model.spoolingDeviceIds = ''
      this.model.devSnAreaLength = 0
      this.model.spunYarnDeviceText = ''
      this.model.spunYarnDeviceIds = ''
      this.model.adeviceText = ''
      this.model.adeviceIds = ''
      this.model.bdeviceText = ''
      this.model.bdeviceIds = ''
      this.model.aproductType = null
      this.model.bproductType = null
      this.model.temOutputRove = null
      this.model.speedSetRove = null

      this.model.dailyPlanSpooling.workshop = null
      this.model.dailyPlanSpooling.company = null
      this.model.dailyPlanSpooling.floor = null
      this.model.dailyPlanSpooling.productType = null
      this.model.dailyPlanSpooling.spoolingDeviceText = ''
      this.model.dailyPlanSpooling.spoolingDeviceIds = ''
      this.model.dailyPlanSpooling.adeviceText = ''
      this.model.dailyPlanSpooling.adeviceIds = ''
      this.model.dailyPlanSpooling.bdeviceText = ''
      this.model.dailyPlanSpooling.bdeviceIds = ''
      this.model.dailyPlanSpooling.aproductType = null
      this.model.dailyPlanSpooling.bproductType = null
      // this.model.dailyPlanSpooling.cproductType = null
      this.model.dailyPlanSpooling.inQuantity = null

      this.model.dailyPlanPreSpin.workshop = null
      this.model.dailyPlanPreSpin.company = null
      this.model.dailyPlanPreSpin.floor = null
      this.model.dailyPlanPreSpin.productType = null
      this.model.dailyPlanPreSpin.productType = null
      this.model.dailyPlanPreSpin.preSpinDeviceText = ''
      this.model.dailyPlanPreSpin.preSpinDeviceIds = ''
      this.model.dailyPlanPreSpin.adeviceText = ''
      this.model.dailyPlanPreSpin.adeviceIds = ''
      this.model.dailyPlanPreSpin.bdeviceText = ''
      this.model.dailyPlanPreSpin.bdeviceIds = ''
      // this.model.dailyPlanPreSpin.cdeviceText = ''
      // this.model.dailyPlanPreSpin.cdeviceIds = ''
      this.model.dailyPlanPreSpin.aproductType = null
      this.model.dailyPlanPreSpin.bproductType = null
      // this.model.dailyPlanPreSpin.cproductType = null
      this.model.dailyPlanPreSpin.fixWeight = null

      this.$refs.form.resetFields()
    },
    changeAStartTime(date, dateString) {
      this.model.aStartTime = dateString
    },
    changeAEndTime(date, dateString) {
      this.model.aEndTime = dateString
    },
    changeBStartTime(date, dateString) {
      this.model.bStartTime = dateString
    },
    changeBEndTime(date, dateString) {
      this.model.bEndTime = dateString
    },
    changeAStartTimeLuoTong(date, dateString) {
      this.model.dailyPlanSpooling.aStartTime = dateString
    },
    changeAEndTimeLuoTong(date, dateString) {
      this.model.dailyPlanSpooling.aEndTime = dateString
    },
    changeBStartTimeLuoTong(date, dateString) {
      this.model.dailyPlanSpooling.bStartTime = dateString
    },
    changeBEndTimeLuoTong(date, dateString) {
      this.model.dailyPlanSpooling.bEndTime = dateString
    },
    changeAStartTimeQianFang(date, dateString) {
      this.model.dailyPlanPreSpin.aStartTime = dateString
    },
    changeAEndTimeQianFang(date, dateString) {
      this.model.dailyPlanPreSpin.aEndTime = dateString
    },
    changeBStartTimeQianFang(date, dateString) {
      this.model.dailyPlanPreSpin.bStartTime = dateString
    },
    changeBEndTimeQianFang(date, dateString) {
      this.model.dailyPlanPreSpin.bEndTime = dateString
    },
    // changeCStartTimeQianFang(date, dateString) {
    //   this.model.dailyPlanPreSpin.cStartTime = dateString
    // },
    // changeCEndTimeQianFang(date, dateString) {
    //   this.model.dailyPlanPreSpin.cEndTime = dateString
    // },
    changeCompany(val) {
      this.adds.changeCompany = val
      this.model.dailyPlanSpooling.company = val
      this.model.dailyPlanPreSpin.company = val
    },
    changeWorkShop(val) {
      this.adds.workshop = val
      this.model.dailyPlanSpooling.workshop = val
      this.model.dailyPlanPreSpin.workshop = val
    },
    changeFloor(val) {
      this.adds.floor = val
      this.model.dailyPlanSpooling.floor = val
      this.model.dailyPlanPreSpin.floor = val
    },
    handleOk() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          let formData = Object.assign(this.model)
          console.log('formData', formData)
          //时间格式化
          httpAction(httpurl, formData, method)
            .then(res => {
              if (res.success) {
                this.$message.success(res.message != '' ? res.message : '执行成功')
                this.$emit('ok')
              } else {
                this.$message.warning(res.message)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
        } else {
          return false
        }
      })
    },

    handleCancel() {
      this.close()
    },
    ktOpen(param) {
      if (this.adds.devSnArea.length > 0) {
        this.$refs.xishaModal.show(this.adds, param, true)
      } else {
        message.warning('请先选择细纱机台！')
      }
    },
    ktOpenQianFang(param, ktOpen) {
      this.$refs.qianfangModal.show(this.addsQianFang, param, true, false, ktOpen)
    },
    showModal(param) {
      if (this.model.workshop && this.model.workshop != 'null') {
        this.$refs.xishaModal.show(this.adds, param, true)
      } else {
        message.warning('请先选择车间！')
      }
    },
    showModalLuoTong(param) {
      this.$refs.luotongJitaiModal.show(this.dailyPlanSpooling, param, true)
    },
    // 切换pz
    changePz(val) {
      this.add.pzja = val
      this.add.pzyb = val
      this.model.aproductType = val
      this.model.bproductType = val

      const param = {
        id: val
      }
      productTypeSpunYarn(param).then(res => {
        if (res.result.records.length > 0) {
          const query = {
            productCode: res.result.records[0].productCode.trim()
          }
          productTypeRoveList(query).then(resp => {
            if (resp.result.records.length > 0) {
              this.model.dailyPlanPreSpin.productType = resp.result.records[0].id.trim()
              this.model.dailyPlanPreSpin.aproductType = resp.result.records[0].id.trim()
              this.model.dailyPlanPreSpin.bproductType = resp.result.records[0].id.trim()
              // this.model.dailyPlanPreSpin.cproductType = resp.result.records[0].id.trim()
            } else {
              this.model.dailyPlanPreSpin.aproductType = null
              this.model.dailyPlanPreSpin.productType = null
              this.model.dailyPlanPreSpin.bproductType = null
              // this.model.dailyPlanPreSpin.cproductType = null
            }
          })
          const queryLuoTong = {
            productType: res.result.records[0].productType.trim()
          }
          productTypeSpoolingList(queryLuoTong).then(resp => {
            if (resp.result.records.length > 0) {
              this.model.dailyPlanSpooling.productType = resp.result.records[0].id.trim()
              this.model.dailyPlanSpooling.aproductType = resp.result.records[0].id.trim()
              this.model.dailyPlanSpooling.bproductType = resp.result.records[0].id.trim()
            } else {
              this.model.dailyPlanSpooling.productType = null
              this.model.dailyPlanSpooling.aproductType = null
              this.model.dailyPlanSpooling.bproductType = null
            }
          })
        }
      })
    },
    // 络筒品种改变
    changePzLuoTong(val) {
      this.model.dailyPlanSpooling.aproductType = val
      this.model.dailyPlanSpooling.bproductType = val
      // this.model.dailyPlanSpooling.cproductType = val
    },
    // 前纺品种改变
    changeQianFang(val) {
      console.log('前纺品种改变=='+val)
      this.model.dailyPlanPreSpin.aproductType = val
      this.model.dailyPlanPreSpin.bproductType = val
      // this.model.dailyPlanPreSpin.cproductType = val
    },
    // 获取选择的数量
    calculateQuantity(arr) {
      let selNum = 0
      arr.forEach(item => {
        selNum += item.devSnArea.length
      })
      return selNum
    },
    getDevSnArr(params, arr, choseDevideIds) {
      arr.forEach(item => {
        item.devSnArea.sort((a, b) => parseInt(a.devSn) - parseInt(b.devSn))
      })
      if (params == 'equipmentScope') {
        this.adds[params] = arr
        this.model.roveDeviceText = this.getSeiresDevsnCs(arr)
        this.model.roveDeviceIds = choseDevideIds.join(',')
      } else if (params == 'equipmentScopeLt') {
        this.adds[params] = arr
        this.model.spoolingDeviceText = this.getSeiresDevsnCs(arr)
        this.model.spoolingDeviceIds = choseDevideIds.join(',')
      } else if (params == 'devSnArea') {
        this.adds[params] = arr
        this.adds.devSnAreaLength = this.calculateQuantity(arr)

        this.model.spunYarnDeviceText = this.getSeiresDevsnCs(arr)
        // this.model.spunYarnDeviceText = this.getSeiresDevsn(arr);
        this.model.spunYarnDeviceIds = choseDevideIds.join(',')

        this.adds['jakt'] = arr
        this.adds.jaktLength = this.calculateQuantity(arr)
        this.model.adeviceText = this.getSeiresDevsnCs(arr)
        this.model.adeviceIds = choseDevideIds.join(',')

        this.adds['ybkt'] = arr
        this.adds.ybktLength = this.calculateQuantity(arr)
        this.model.bdeviceText = this.getSeiresDevsnCs(arr)
        this.model.bdeviceIds = choseDevideIds.join(',')
      } else if (params == 'jakt') {
        this.adds['jakt'] = arr
        this.adds.jaktLength = this.calculateQuantity(arr)
        this.model.adeviceText = this.getSeiresDevsnCs(arr)
        // this.model.adeviceText = this.getSeiresDevsn(arr);
        this.model.adeviceIds = choseDevideIds.join(',')
      } else if (params == 'ybkt') {
        this.adds['ybkt'] = arr
        this.adds.ybktLength = this.calculateQuantity(arr)
        // this.model.bdeviceText = this.getSeiresDevsn(arr);
        this.model.bdeviceText = this.getSeiresDevsnCs(arr)
        this.model.bdeviceIds = choseDevideIds.join(',')
      }
      this.calQk()
    },
    getDevSnArrLuoTong(params, arr, choseDevideIds) {
      arr.forEach(item => {
        item.devSnArea.sort((a, b) => parseInt(a.devSn) - parseInt(b.devSn))
      })
      if (params == 'equipmentScopeLt') {
        this.dailyPlanSpooling[params] = arr
        // this.model.spoolingDeviceText = this.getSeiresDevsnCs(arr)
        // this.model.spoolingDeviceIds = choseDevideIds.join(',')
        this.model.dailyPlanSpooling.spoolingDeviceText = this.getSeiresDevsnCs(arr)
        this.model.dailyPlanSpooling.spoolingDeviceIds = choseDevideIds.join(',')

        this.dailyPlanSpooling['jakt'] = arr
        this.model.dailyPlanSpooling.adeviceText = this.getSeiresDevsnCs(arr)
        this.model.dailyPlanSpooling.adeviceIds = choseDevideIds.join(',')

        this.dailyPlanSpooling['ybkt'] = arr
        this.model.dailyPlanSpooling.bdeviceText = this.getSeiresDevsnCs(arr)
        this.model.dailyPlanSpooling.bdeviceIds = choseDevideIds.join(',')
      } else if (params == 'jakt') {
        this.dailyPlanSpooling['jakt'] = arr
        this.model.dailyPlanSpooling.adeviceText = this.getSeiresDevsnCs(arr)
        // this.model.adeviceText = this.getSeiresDevsn(arr);
        this.model.dailyPlanSpooling.adeviceIds = choseDevideIds.join(',')
      } else if (params == 'ybkt') {
        this.dailyPlanSpooling['ybkt'] = arr
        // this.model.bdeviceText = this.getSeiresDevsn(arr);
        this.model.dailyPlanSpooling.bdeviceText = this.getSeiresDevsnCs(arr)
        this.model.dailyPlanSpooling.bdeviceIds = choseDevideIds.join(',')
      }
    },
    getDevSnArrQianFang(params, arr, choseDevideIds, ktOpen) {
      arr.forEach(item => {
        item.devSnArea.sort((a, b) => parseInt(a.devSn) - parseInt(b.devSn))
      })
      if (!ktOpen) {
        if (params == 'CuSha') {
          this.addsQianFang[params] = arr
          this.model.dailyPlanPreSpin.preSpinDeviceText = this.getSeiresDevsnCs(arr)
          this.model.dailyPlanPreSpin.preSpinDeviceIds = choseDevideIds.join(',')

          this.addsQianFang['jakt'] = arr
          this.model.dailyPlanPreSpin.adeviceText = this.getSeiresDevsnCs(arr)
          this.model.dailyPlanPreSpin.adeviceIds = choseDevideIds.join(',')

          this.addsQianFang['ybkt'] = arr
          this.model.dailyPlanPreSpin.bdeviceText = this.getSeiresDevsnCs(arr)
          this.model.dailyPlanPreSpin.bdeviceIds = choseDevideIds.join(',')

          // this.addsQianFang['bckt'] = arr
          // this.model.dailyPlanPreSpin.cdeviceText = this.getSeiresDevsnCs(arr)
          // this.model.dailyPlanPreSpin.cdeviceIds = choseDevideIds.join(',')
        }
      } else {
        if (ktOpen == 'jakt') {
          this.addsQianFang['jakt'] = arr
          this.model.dailyPlanPreSpin.adeviceText = this.getSeiresDevsnCs(arr)
          this.model.dailyPlanPreSpin.adeviceIds = choseDevideIds.join(',')
        } else if (ktOpen == 'ybkt') {
          this.addsQianFang['ybkt'] = arr
          this.model.dailyPlanPreSpin.bdeviceText = this.getSeiresDevsnCs(arr)
          this.model.dailyPlanPreSpin.bdeviceIds = choseDevideIds.join(',')
        }
        // else if (ktOpen == 'bckt') {
        //   this.addsQianFang['bckt'] = arr
        //   this.model.dailyPlanPreSpin.cdeviceText = this.getSeiresDevsnCs(arr)
        //   this.model.dailyPlanPreSpin.cdeviceIds = choseDevideIds.join(',')
        // }
      }
    },
    calQk() {
      // let devSn = this.adds.devSnArea.length
      // let ja = this.adds.jakt.length
      // let yb = this.adds.ybkt.length
      // this.adds.qk = devSn - (ja + yb) * 0.5
      // this.model.unOpen = devSn - (ja + yb) * 0.5
      let devSn = this.adds.devSnAreaLength
      let ja = this.adds.jaktLength
      let yb = this.adds.ybktLength
      this.adds.qk = devSn - (ja + yb) * 0.5
      // this.model.unOpen = devSn - (ja + yb) * 0.5
    },
    // 获取连续机台-粗纱
    getSeiresDevsnCs(arr) {
      let str = ''
      arr.map(item => {
        let itemStr = `${item.cj}：${this.getSeiresDevsn(item.devSnArea)}`
        str += itemStr + '；'
      })
      str = str.substring(0, str.length - 1)
      return str
    },
    // 获取连续车台
    getSeiresDevsn(arr) {
      if (arr) {
        var result = [],
          i = 0,
          str = ''
        if (arr.length > 0) {
          result[i] = [arr[0].devSn]
          arr.reduce(function(prev, cur) {
            parseInt(cur.devSn) - parseInt(prev.devSn) == 1 ? result[i].push(cur.devSn) : (result[++i] = [cur.devSn])
            return cur
          })
          result.map(item => {
            if (item.length > 1) {
              str += `#${item[0]}~#${item[item.length - 1]},`
            } else {
              str += `#${item[0]},`
            }
          })
          str = str.substring(0, str.length - 1)
        } else {
          str = ''
        }
        return str
      }
    }
  }
}
</script>

<style scoped></style>
